<template>
	<view class="box">
		<view class="box-list">
			<!-- 历史问诊列表 -->
			<view class="list-count" v-if="list.length>0" v-for="item in list" :key="item.id">
				<view class="count-header">
					<view class="header-left">
						<text>订单号: {{item.orderNum}}</text>
					</view>
					<text class="money">¥ {{item.consultationFee}}</text>
				</view>
				<view class="count-body">
					<view class="body-header">
						<text>{{item.client.realName}}</text>
						<view class="header-back">{{item.client.sex===1?'男':'女'}}</view>
						<view class="header-back">{{item.client.age}}岁</view>
					</view>
					<view class="body-text">发病时间 : {{item.morbidityTime?item.morbidityTime:'无'}}</view>
					<view>主要临床表现: 声音沙哑丶发热</view>
				</view>
				<view class="count-footer">
					<view>医生信息</view>
					<view class="list-box">
						<image src="@/static/image/doctor.jpg" mode=""></image>
						<view class="list-count1">
							<text>{{item.doctorUser.realName}} {{item.doctorUser.occupationTitle}}</text>
							<text class="title">{{item.doctorUser.hospital}} | {{item.doctorUser.administrativeOffice}}</text>
							<u--text :lines="2" size="22rpx"
								:text="'擅长:'+item.doctorUser.personalExpertise"></u--text>
						</view>
						<view class="list-btn">
							<u-button  v-if="item.status===4" size="mini" shape="circle" color="#bbbbbb">已完结</u-button>
							<u-button v-if="item.status===3" size="mini" shape="circle" color="#f9ae3d" @click="toChat(item)">立即沟通</u-button>
							<u-button  v-if="item.status===2" size="mini" shape="circle" color="#18b566">待接诊</u-button>
						</view>
					</view>
					<u-button :disabled="item.status!==4" @click="toResult(item.id)" type="success" height="50rpx" shape="circle" color="#54b6ab">医生接诊结果</u-button>
				</view>
			</view>
		
			<view v-if="list.length==0">
				<u-empty
				        mode="history"
				        icon="http://cdn.uviewui.com/uview/empty/history.png"
				>
				</u-empty>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			};
		},
		onShow() {
			this.findAll()
		},
		methods: {
			//查看诊断结果
			toResult(id){
				uni.navigateTo({
					url:'/pages/consultationResults?id='+id
				})
			},
			async findAll() {
				const {
					data
				} = await uni.$http.post('/patient-interrogationRecords/findAll')
				if (data.code === 200) {
					this.list = data.data
				}
			},
			toChat(obj) {
				uni.navigateTo({
					url: '/pages/chat?name=' + obj.doctorUser.realName + "&userId=" + obj.doctorId+"&clientName="+obj.client.realName
				})
			}
		}
	}
</script>

<style lang="scss">
	.box {
		width: 100%;
		height: 100%;
		background-color: #f2f2f2;
		overflow: auto;

		.box-header {
			width: 100%;
			height: 7%;
			background-color: #fff;
			display: flex;
			align-items: center;
			justify-content: space-around;

			.header-nav {
				width: 20%;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				box-sizing: border-box;
				transition: all .3s;
			}

			.active {
				color: #54b6ab;
				border-bottom: 8rpx solid #54b6ab;
			}
		}

		.box-list {
			width: 100%;
			height: 90%;
			padding: 20rpx;
			margin-bottom: 20rpx;
			box-sizing: border-box;

			.list-count {
				width: 100%;
				background-color: #fff;
				border-radius: 20rpx;
				padding: 20rpx;
				margin-bottom: 20rpx;
				box-sizing: border-box;

				.count-header {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.header-left {
						display: flex;
						align-items: center;

						text {
							margin-right: 20rpx;
						}
					}

					.money {
						color: red;
						font-weight: bold;
					}
				}

				.count-body {
					margin: 20rpx 0;
					width: 100%;
					padding: 20rpx;
					box-sizing: border-box;
					background-color: #f2f2f2;

					.body-header {
						display: flex;
						align-items: center;

						.header-back {
							margin: 0 20rpx;
							padding: 5rpx 20rpx;
							border-radius: 8rpx;
							background-color: #54b6ab;
							color: #fff;
						}
					}

					.body-text {
						margin: 10rpx 0;
						box-sizing: border-box;
					}
				}

				.count-footer {
					width: 100%;

					.list-box {
						width: 100%;
						padding: 20rpx;
						box-sizing: border-box;
						display: flex;
						align-items: stretch;
						justify-content: space-between;

						image {
							width: 100rpx;
							height: 100rpx;
						}

						.list-count1 {
							width: calc(100% - 300rpx);
							display: flex;
							flex-direction: column;

							.title {
								margin: 10rpx 0;
							}

							.count {
								word-break: break-all;
								text-overflow: ellipsis;
								display: -webkit-box;
								-webkit-box-orient: vertical;
								-webkit-line-clamp: 2;
								overflow: hidden;
							}
						}

						.list-btn {
							width: 140rpx;
							display: flex;
							flex-direction: column;
							align-items: flex-end;
							justify-content: flex-start;
						}
					}
				}
			}
		}
	}
</style>